﻿Ext.override(Ext.form.field.ComboBox, {
    onDestroy: function () {
        this.bindStore(null);

        this.callParent();
    },
    onTypeAhead: function () {
        var me = this, displayField = me.displayField,
        record = me.store.findRecord(displayField, me.getRawValue()),
        boundList = me.getPicker(), newValue, len, selStart;
        Kwan.Debug(me);
        if (record) {
            newValue = record.get(displayField);
            len = newValue.length;
            selStart = me.getRawValue().length;

            try {// 加个判断免得里面是grid的时候出错
                boundList.highlightItem(boundList.getNode(record));
            } catch (e) {

            }

            if (selStart !== 0 && selStart !== len) {
                me.setRawValue(newValue);
                me.selectText(selStart, newValue.length);
            }
        }
    }
});